home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group98c.txt / 000068_icon-group-sender _Tue Nov 3 12:33:05 1998.msg < prev    next >
Internet Message Format  |  2000-09-20  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) with SMTP id MAA19788
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Tue, 3 Nov 1998 12:33:04 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA14807; Tue, 3 Nov 1998 12:32:27 -0700
  7. Date: Tue, 3 Nov 1998 09:30:12 -0700
  8. From: swampler@noao.edu (Steve Wampler)
  9. Subject: Re: How to read integers and others
  10. To: icon-group@optima.CS.Arizona.EDU
  11. Message-Id: <swampler-9810031630.AA002220442@orpheus.gemini.edu>
  12. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  13. Status: RO
  14.  
  15.  
  16.  
  17. - Forwarded message from rpereda@ringer.cs.utsa.edu on Mon, 2 Nov 1998 18:48:09 -0600 (CST) -
  18. > # Please RTFM, "String Scanning and Pattern Matching" chapter
  19. > # in the Icon book, or scanning in one of the many online reference
  20. > # documents.
  21. > # Also, start by reading http://www.cs.arizona.edu/icon/intro.htm
  22. > procedure main()
  23. >    while line := read() ? {
  24. >       tab(upto(&letters))
  25. >       word := tab(many(&letters))
  26. >       tab(upto(&digits))
  27. >       num := integer(tab(many(&digits)))
  28. >       write("number: ", num, " word: ", word)
  29. >     }
  30. > end
  31. > -ray
  32.  
  33. As I understand Robert's question, the above program will not work.  He
  34. appears to want to scan in 32-bit integers, not ascii strings that 'look
  35. like' integers.  That is, each word in his list is followed by the
  36. 4 bytes for the 32-bit integer (2's-complement, I assume).
  37.  
  38. Robert, if I'm correct in how I'm interpreting your question, this
  39. isn't that easy to do directly in Icon.  You'd have to read in the
  40. 4 bytes with reads() and the figure out to reconstruct the integer
  41. from that 4-byte string of ascii.  (This isn't too hard if you
  42. are dealing with only non-negative values [the ord() function can
  43. help] but handling the 2-s complement for negative values strikes me
  44. as ugly.)
  45.  
  46. Somebody has probably done this already.
  47.  
  48. Incidently, you'd be better off if you used printf in your C retrieve
  49. program to output the 32-bit integer as it's ascii equivalent, in which
  50. case you could use a technique such as the one Ray suggests above.
  51.  
  52. > On 2 Nov 1998, Robert Valliant wrote:
  53. > > I have an information retrieval program written in "c" that I would
  54. > > like to convert to a web application.
  55. > > 
  56. > > The indexing portion of the application generates an inverted file of
  57. > > the format:
  58. > > 
  59. > >     word   32-bit integer
  60. > >     word   32-bit integer
  61. > >         .
  62. > >         .
  63. > >         .
  64. > >     word 32-bit integer
  65. > > 
  66. > > Can anyone tell me the best way to read these things, using icon? Or
  67. > > am I wasting my time in trying?
  68.  
  69. --
  70. Steve Wampler - swampler@gemini.edu [Gemini 8m Telescopes Project (under AURA)]
  71. The gods that smiled at your birth are now laughing openly. (Fortune Cookie)
  72.